// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

namespace Stride.Core.Serialization;

public abstract class ClassDataSerializer<T> : DataSerializer<T> where T : class, new()
{
    /// <inheritdoc/>
    public override void PreSerialize(ref T obj, ArchiveMode mode, SerializationStream stream)
    {
        if (mode == ArchiveMode.Deserialize && obj == null)
        {
            obj = new T();
        }
    }
}
